package com.tanhua.model.vo;

import com.baomidou.mybatisplus.annotation.TableField;
import com.tanhua.model.domain.UserInfo;
import com.tanhua.model.mongo.Voice;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;


import java.io.Serializable;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class VoiceVo implements Serializable {

    private Long created; //创建时间
    private String voiceUrl; //音频文件，URL
    private Integer id;  //用户id

    private String nickname; //昵称
    private String avatar; //用户头像
    private String gender; //性别
    private Integer age; //年龄

    private Integer remainingTimes; // 剩余次数

    public static VoiceVo init(UserInfo userInfo, Voice item) {
        VoiceVo voiceVo = new VoiceVo();
        //copy用户属性
        BeanUtils.copyProperties(userInfo,voiceVo);  //source,target
        if(userInfo.getAge() != null){
            voiceVo.setAge(Integer.valueOf(userInfo.getAge()));
        }
        //copy视频属性
        BeanUtils.copyProperties(item,voiceVo);
        voiceVo.setId(userInfo.getId().intValue());
        return voiceVo;
    }
}